package com.zzh.takeoutapp.event;

/**
 * @author
 * @Name: MsgEvent
 * @Description: ${todo}
 * @date
 * @time
 * @copyright
 */
public class MsgEvent {
    static volatile long event_id = 0;
    //存储类别
    protected Object _msgType;
    protected boolean _flag = true; //真 假标识,标识通讯成功还是失败,无关业务逻辑
    protected String _errorString = "";
    protected int _statusCode = -1;//默认是一个http协议以外的状态码

    public MsgEvent() {
        _msgType = "MsgEventDefault";
    }

    public void setMsgType(Object obj) {
        _msgType = obj;
    }

    public Object getMsgType() {
        return _msgType;
    }

    public String getErrorString() {
        return _errorString;
    }

    public void setErrorString(String err) {
        _errorString = err;
    }

    public void setFlag(boolean flag) {
        _flag = flag;
    }

    public boolean getFlag() {
        return _flag;
    }

    public void setStatusCode(int statusCode) {
        _statusCode = statusCode;
    }

    public int getStatusCode() {
        return _statusCode;
    }

    //多线程安全,全局生成唯一的id不重复.用户在没销毁应用前,获得的消息id都不会重复
    //id不能存储在硬盘上,每次启动时,id都会从1开始计时
    public synchronized static long createEventId() {
        MsgEvent.event_id = MsgEvent.event_id + 1;
        return event_id;
    }


}
